#include "spaceShip.h"

spaceShip::spaceShip()
{

}

void spaceShip::setValues(double x,double y,double a,int gas)
{
	this->pos.x=x;
	this->pos.y=y;
	this->v.x=0;
	this->v.y=0;
	this->dv=0;
	this->s=0;
	this->a=a;
	this->gas=gas;
	this->thrust.x=0;
	this->thrust.y=0;	
}

void spaceShip::claculate(double dt)
{
	this->dv=(a-this->thrust.y)*dt;
	this->v.y+=dv;
	this->pos.y+=dt*v.y;


	this->dv=(this->thrust.x)*dt;
	this->v.x+=dv;
	this->pos.x+=dt*v.x;
}

void spaceShip::moveUp(double power)
{
	if(this->gas>1)
	{
		this->thrust.y=power;
		this->gas--;
	}
	this->claculate(0.1);
}

void spaceShip::moveSidewards(double power)
{
	if(this->gas>1)
	{
		this->thrust.x=power;
		this->gas--;
	}
	this->claculate(0.1);
}

void spaceShip::setThrust()
{
	this->thrust.x=0;
	this->thrust.y=0;

}

double* spaceShip::getX()
{
	return &this->pos.x;
}

double* spaceShip::getY()
{
	return &this->pos.y;
}

int* spaceShip::getGas()
{
	return &this->gas;
}

double* spaceShip::getSpeed()
{
	return &this->v.y;
}